<template>
	<view class="news" >
		<view class="news-item" v-for="(item,index) in newsData" :key="item.id" @click="sendId(item.id)">
			<image :src="item.img_url"></image>
			<view class="right">
				<view class="title">
					{{item.title}}
				</view>
				<view class="info">
					<text>创建时间：{{item.add_time | dateFormat}}</text>
					<text>浏览：{{item.click}} </text>
				</view>
				
			</view>
		</view>
	</view>
</template>

<script>
	export default{
		props:['newsData'],
		filters:{
			dateFormat(str){
				return str.slice(0,10)
				// const newDate = new Date(str)
				// const year = newDate.getFullYear()
				// const month = newDate.getMonth()
				// const day = newDate.getDay()
			}
		},
		methods:{
			sendId(id){
				this.$emit("sendIdEvent",id)
			}
		}
	}
</script>


<style lang="scss">
.news{
	.news-item{
		display: flex;
		padding: 10rpx ;
		border-bottom: 1px solid $shop-color;
		image{
			min-width: 200rpx;
			max-width: 200rpx;
			height: 150rpx;
			margin-right: 20rpx;
		}
		.right{
			display: flex;
			flex-direction: column;
			justify-content: space-between;
			.title{
				font-size: 40rpx;
				margin-bottom: 10rpx;
			}
			.info{
				font-size: 25rpx;
				text:nth-child(1){
					margin-right: 30rpx;
				}
			}
		}
	}
}
	
</style>
